<template>
<div class="ContList">
    <!--评价导航-->
    <van-nav-bar fixed title="评价详情页" left-arrow @click-left="$router.go(-1)" />
    <div class="nav-bar">
        <van-tabs >
            <van-tab >
            <template #title> 全部(14) </template>
            </van-tab>
            <van-tab >
            <template #title> 好评(14) </template>
            </van-tab>
            <van-tab >
            <template #title> 中评(14) </template>
            </van-tab>
            <van-tab >
            <template #title> 差评(14) </template>
            </van-tab>
            <div class="comment-list">
        <div class="comment-item" v-for="item in CommentsdList" :key="item.comment_id">
          <div class="top">
            <img :src="item.user.avatar_url || defaultImg">
            <div class="name">{{ item.user.nick_name }}</div>
            <van-rate :size="16" :value="item.score/2" color="#ffd21e" void-icon="star" void-color="#eee"/>
          </div>
          <div class="content">
            {{item.content}}
          </div>
          <div class="time">
            {{item.create_time}}
          </div>
        </div>
      </div>
        </van-tabs>
    </div>
    <!--评价内容-->

<div>
</div>
</div>
</template>

<script>
import { getCommentList } from '@/api/commodity'
import defaultImg from '../../assets/default-avatar.png'
export default {
  name: 'ContList',
  data () {
    return {
      CommentsdList: [], // 评论列表
      total: 0, // 总数量
      defaultImg, // 默认头像
      score: '' // 评分
    }
  },
  methods: {
    async getList () {
      const { data: { list, total } } = await getCommentList(this.goodsId, 15)
      this.CommentsdList = list
      this.total = total
      // this.score = list[12].score
      const obj = { ...this.CommentsdList }
      this.score = obj[3].score
    }
  },
  computed: {
    goodsId () {
      return this.$route.query.goodsId
    }
  },
  created () {
    this.getList()
  }
}

</script>

<style lang="less">
.ContList{
    .nav-bar{
        margin-top: 40px;
    }
    .comment-item {
    font-size: 16px;
    line-height: 30px;
    padding: 20px;
    .top {
      height: 30px;
      display: flex;
      align-items: center;
      margin-top: 20px;
      img {
        width: 20px;
        height: 20px;
      }
      .name {
        margin: 0 10px;
      }
    }
    .time {
      color: #999;
    }
  }
}
</style>
